package org.jeecg.modules.vital.service.impl;

import org.jeecg.modules.vital.entity.InspectionRecodes;
import org.jeecg.modules.vital.entity.TestRecodes;
import org.jeecg.modules.vital.entity.ExamineRecodes;
import org.jeecg.modules.vital.entity.Reports;
import org.jeecg.modules.vital.mapper.TestRecodesMapper;
import org.jeecg.modules.vital.mapper.ExamineRecodesMapper;
import org.jeecg.modules.vital.mapper.ReportsMapper;
import org.jeecg.modules.vital.mapper.InspectionRecodesMapper;
import org.jeecg.modules.vital.service.IInspectionRecodesService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.io.Serializable;
import java.util.List;
import java.util.Collection;

/**
 * @Description: 检查与检验记录
 * @Author: jeecg-boot
 * @Date:   2023-01-04
 * @Version: V1.0
 */
@Service
public class InspectionRecodesServiceImpl extends ServiceImpl<InspectionRecodesMapper, InspectionRecodes> implements IInspectionRecodesService {

	@Autowired
	private InspectionRecodesMapper inspectionRecodesMapper;
	@Autowired
	private TestRecodesMapper testRecodesMapper;
	@Autowired
	private ExamineRecodesMapper examineRecodesMapper;
	@Autowired
	private ReportsMapper reportsMapper;
	
	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delMain(String id) {
		testRecodesMapper.deleteByMainId(id);
		examineRecodesMapper.deleteByMainId(id);
		reportsMapper.deleteByMainId(id);
		inspectionRecodesMapper.deleteById(id);
	}

	@Override
	@Transactional(rollbackFor = Exception.class)
	public void delBatchMain(Collection<? extends Serializable> idList) {
		for(Serializable id:idList) {
			testRecodesMapper.deleteByMainId(id.toString());
			examineRecodesMapper.deleteByMainId(id.toString());
			reportsMapper.deleteByMainId(id.toString());
			inspectionRecodesMapper.deleteById(id);
		}
	}
	
}
